/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Review.test1;

/**
 *
 * @author THIEN
 */
public class ThreadTwo implements Runnable {

    Thread t;
    Data d;

    public ThreadTwo(Data d) {
        this.d = d;
        t = new Thread(this);
        t.start();
    }

    public void run() {
        //throw new UnsupportedOperationException("Not supported yet.");
        while (true) {
            synchronized (this.d) {
                if (d.flag) {
                    d.display();
                    d.flag = false;
                }
            }
        }
    }
}
